package com.heima.controller;


import com.heima.pojo.dto.VmTypeAddDto;
import com.heima.pojo.dto.VmTypeSearchDto;
import com.heima.pojo.dto.VmTypeUpdateDto;
import com.heima.pojo.vo.PageResponseVo;
import com.heima.pojo.vo.VmTypeVo;
import com.heima.service.VmTypeService;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 设备类型接口
 */
@RestController
@RequestMapping("/api/vm-service/vmType")
public class VmTypeController {

    @Autowired
    private VmTypeService vmTypeService;

    //分页查询展示设备类型数据
    @GetMapping("/search")
    public PageResponseVo<VmTypeVo> searchVmType(VmTypeSearchDto vmTypeSearchDto) {
        return vmTypeService.selectVmType(vmTypeSearchDto);
    }

    //新增设备类型
    @PostMapping
    public Boolean addVmType(@RequestBody VmTypeAddDto vmTypeAddDto) {
        return vmTypeService.addVmType(vmTypeAddDto);
    }
    //修改设备类型数据
    @PutMapping("/{typeId}")
    public Boolean updateVmTypeByTypeId(@PathVariable Integer typeId, @RequestBody VmTypeUpdateDto vmTypeUpdateDto) {
        return vmTypeService.updateVmTypeByTypeId(typeId, vmTypeUpdateDto);
    }
    //删除设备类型数据
    @DeleteMapping("/{typeId}")
    public Boolean deleteVmTypeByTypeId(@PathVariable Integer typeId) {
        return vmTypeService.deleteVmTypeByTypeId(typeId);
    }
}
